package com.inspectortime.util;

import java.io.File;
import java.io.IOException;

import org.springframework.util.FileCopyUtils;

public class DirectoryCopyUtils {
	
	private DirectoryCopyUtils() {}
	
	/**
	 * Copies all files in srcDir to targetDir. Ignores any directories in source.
	 */
	public static void copyAll(File srcDir, File targetDir) throws IOException {
		for (int i = 0; i < srcDir.listFiles().length; i++) {
			File srcFile = srcDir.listFiles()[i];
			if (srcFile.isFile()) {
				File targetFile = new File(targetDir, srcFile.getName());
				FileCopyUtils.copy(srcFile, targetFile);				
			}
		}		
	}

}
